package test.reflection.Streams;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author duWenJian
 * @Date 2024/2/29 21:39
 * @Version 1.0
 */
public class test01 {
    public static void main(String[] args) {
        List<Person> lists = new ArrayList<>();
        Person p1 = new Person("张三", "北京");
        Person p2 = new Person("李四", "上海");
        Person p3 = new Person("王五", "广州");
        Person p4 = new Person("张三", "深圳");
        lists.add(p1);
        lists.add(p2);
        lists.add(p3);
        lists.add(p4);
        Map<String, Object> collect = lists.stream()
                .collect(Collectors.toMap(Person::getName,Person::getName, (person1, person2) -> person1));
        System.out.println(collect);
    }
}
